Skip to main content

ML Trainer

This is the process of teaching a machine learning model (only support regression and classification) to make accurate predictions by adjusting its parameters using labeled data. It involves optimizing a specific objective function and aims to create a model that generalizes well to new data.

Method: POST Authorization: API Key
https://engine.raccoon-ai.io/api/v1/trainer/ml/new/<algo_type>/<algo_selected>

<algo_type> and <algo_selected> references as below,

<algo_type><algo_selected>
regressionann , grad-boost, log-reg, multi-linear, random-forest
classificationann, grad-boost, naive-bayes, random-forest, svm

Authorization

TypeKeyValue
API KeyX-Api-Keyrae_##########

Request Body

SectionKeyData TypeRequiredDescription
traindatajsontrueData that use to train the model
featureslisttrueInput features (X)
targetslisttrueOutput targets (y)
configjsonfalseConfigurations for training
hyper_paramsjsonfalseHyper parameters for training (For more about each algorithm's hyper_params, refer Quick Analysis section)
projectproject_idstringtrueID of the project (Refer Create Project to obtain a project ID)

Types

{
"train": {
"data": <json>,
"features": <list>,
"targets": <list>,
"config": <json>,
"hyper_params": <json>
},
"project_id": <string>
}

Sample

{
"train": {
"data": {
"R&D Spend": {
"0": 165349.2,
"1": 162597.7,
"2": 153441.51,
"3": 144372.41,
"4": 142107.34,
"5": 131876.9,
"6": 134615.46,
"7": 130298.13,
"8": 120542.52,
"9": 123334.88
},
"Administration": {
"0": 136897.8,
"1": 151377.59,
"2": 101145.55,
"3": 118671.85,
"4": 91391.77,
"5": 99814.71,
"6": 147198.87,
"7": 145530.06,
"8": 148718.95,
"9": 108679.17
},
"Marketing Spend": {
"0": 471784.1,
"1": 443898.53,
"2": 407934.54,
"3": 383199.62,
"4": 366168.42,
"5": 362861.36,
"6": 127716.82,
"7": 323876.68,
"8": 311613.29,
"9": 304981.62
},
"State": {
"0": "New York",
"1": "California",
"2": "Florida",
"3": "New York",
"4": "Florida",
"5": "New York",
"6": "California",
"7": "Florida",
"8": "New York",
"9": "California"
},
"Profit": {
"0": 192261.83,
"1": 191792.06,
"2": 191050.39,
"3": 182901.99,
"4": 166187.94,
"5": 156991.12,
"6": 156122.51,
"7": 155752.6,
"8": 152211.77,
"9": 149759.96
}
},
"features": ["R&D Spend", "Administration", "Marketing Spend", "State"],
"targets": ["Profit"],
"config": {
"std_scale": true,
"encoder": "onehot"
},
"hyper_params": {
"fit_intercept": false
}
},
"project_id": "Project1-96507"
}

Reponse Body

KeyData TypeDescription
successbooleanIndicate the success of the request
msgstringMessage indicators
error_codeintError code information, only set if success is false
resultjsonResult, only set if success is true
gen_atdatetimeGenerated datetime

Types

{
"success": <boolean>,
"msg": <string>,
"error_code": <int | null>,
"result": <json>,
"gen_at": <datetime>
}

Sample

{
"success": true,
"msg": "Model trained successfully",
"error_code": null,
"result": {
"score": {
"train": 0.942446542689397,
"test": 0.9649618042046072
},
"cached_in": {
"id": "1686494510.14959",
"user_id": "7f7c0c39-0930-43f2-81a3-29e3cffecaa4",
"model_path": "/home/navi/CODE/Raccoon-AI-Engine/app/storage/cached/ml/Project1-96507/7f7c0c39-0930-43f2-81a3-29e3cffecaa4/1686494510.14959.jlb",
"features": ["R&D Spend", "Administration", "Marketing Spend", "State"],
"targets": ["Profit"],
"algo_type": "Multiple Linear Regressor",
"types_map": {
"R&D Spend": "float64",
"Administration": "float64",
"Marketing Spend": "float64",
"State": "object",
"Profit": "float64"
},
"project_id": "Project1-96507",
"train_accu": 0.942446542689397,
"test_accu": 0.9649618042046072,
"dataset": null,
"permanent_save": false,
"created_ts": "2023-06-11T20:11:50.155242",
"updated_ts": "2023-06-11T20:11:50.155246",
"hyper_params": {
"fit_intercept": false,
"copy_X": true,
"n_jobs": null,
"positive": false
}
}
},
"gen_at": "2023-06-11T20:11:50.658995"
}